package com.hjx.movie.core.system.service.admin.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hjx.movie.common.utils.ResultType;
import com.hjx.movie.common.utils.exceptions.CustomException;
import com.hjx.movie.common.utils.tree.TreeBuilder;
import com.hjx.movie.core.system.service.admin.IAccountService;
import com.hjx.movie.core.system.service.admin.IApiService;
import com.hjx.movie.core.system.service.admin.IRoleApiService;
import com.hjx.movie.core.system.vo.ApiTreeNode;
import com.hjx.movie.core.util.CombineBeansUtil;
import com.hjx.movie.core.util.cache.CacheKey;
import com.hjx.movie.core.util.cache.CacheUtil;
import com.hjx.movie.persistence.system.mapper.IvyAccountMapper;
import com.hjx.movie.persistence.system.mapper.IvyApiMapper;
import com.hjx.movie.persistence.system.model.IvyAccount;
import com.hjx.movie.persistence.system.model.IvyApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2021/1/8 - 16:26
 */
@Slf4j
@Service
@Transactional
@CacheConfig(cacheNames = "IvyMovie:SpringCache:AccountCache",keyGenerator = "cacheKeyGenerator")
public class AccountService extends ServiceImpl<IvyAccountMapper, IvyAccount> implements IAccountService {

    @Override
    public Boolean addBalance(IvyAccount temp) {
        IvyAccount account = getById(temp.getAccountId());
        account.setBalance(account.getBalance().add(temp.getBalance()));
        return updateById(account);
    }
}
